package com.yxx.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * MyBatis Plus 配置
 * @author yuxiangxun
 * @date 2025/1/18
 * @apiNote
 */
@Configuration
@MapperScan(value = "com.yxx.mapper")
public class MyBatisPlusConfig {
    /**
     * 配置 MyBatis-Plus 的拦截器
     * @return
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        // 创建 MybatisPlusInterceptor 对象
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        // 添加分页拦截器（PaginationInnerInterceptor），用于支持分页功能
        mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());
        // 返回配置好的拦截器
        return mybatisPlusInterceptor;
    }
}
